var express = require('express');
var router = express.Router();
const { addOrders, getOrders, getOrdersById, disposeOrdersToCancel, getToCancelOrders, submitOrdersToCancel, changeOrderById } = require('../service/ordersService');
/* GET home page. */
router.get('/getOrders', async function (req, res, next) {
    const data = await getOrders(req.query)
    res.send(data);
});


router.get('/getToCancelOrders', async function (req, res, next) {
    const data = await getToCancelOrders(req.query)
    res.send(data);
});

router.post('/addOrders', async function (req, res, next) {
    const data = await addOrders(req.body);
    res.send(data);
});


router.get('/getOrdersById', async function (req, res, next) {
    const data = await getOrdersById(req.query)
    res.send(data);
});



router.post('/disposeOrdersToCancel', async function (req, res, next) {
    console.log('接收订单修改请求请求');
    const data = await disposeOrdersToCancel(req.body);
    res.send(data);
});

router.post('/submitOrdersToCancel', async function (req, res, next) {
    console.log('接收订单修改请求请求');
    const data = await submitOrdersToCancel(req.body);
    res.send(data);
});

router.post('/changeOrderById', async function (req, res, next) {
    console.log('接收订单修改请求请求');
    const data = await changeOrderById(req.body);
    res.send(data);
});



module.exports = router;